package properties;
import java.io.*;
import java.util.*;

public class Greeting4
{
     String message;

          public Greeting4()
           {
           message= new String("Hello World");
           }

     public void setMessage()
     {
     //create an instance of properties class

     Properties props = new Properties();

     //try retrieve data from file

               try {

               props.load(new FileInputStream("C:/workspace/TUTO/src/message.properties"));

               // assign value to message variable only if it is not null

                  if(props.getProperty("message") !=null)
                    {
                    message = props.getProperty("message");
                    }

     System.out.println(message);
     }

               //catch exception in case properties file does not exist

               catch(IOException e)
               {
                   System.out.println(message);
                   }
     }

     public static void main(String[] args)
     {
     //create an instance of Greeting4 class

     Greeting4 gr = new Greeting4();

     //call the setMessage() method of the Greeting4 class

     gr.setMessage();
     }
 }